package com.qijian.mold.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 模块角色枚举
 * 0-管理员、1-技术员、2-车间操作员 3-操作工
 * @author anni.zhu
 * @author anni.zhu@king-v.com
 * Created in 2025/3/30 18:58
 */
@Getter
@AllArgsConstructor
public enum MoldRoleEnum {
    ADMIN(0, "mold","管理员"),
    TECHNICIAN(1, "mold_technical","技术员"),
    WORKSHOP_OPERATOR(2, "mold_workshop","车间操作员"),
    WORKER(3,"mold_worker","操作工")
    ;

    @JsonValue
    @EnumValue
    private Integer id;
    private String name;
    private String commit;

    public static String getNameById(Integer id) {
        MoldRoleEnum[] values = MoldRoleEnum.values();
        for (MoldRoleEnum value : values) {
            if (value.id.equals(id)) {
                return value.name;
            }
        }
        return null;
    }


    public static String getIdByName(String Name) {
        MoldRoleEnum[] values = MoldRoleEnum.values();
        for (MoldRoleEnum value : values) {
            if (value.name.equals(Name)) {
                return value.name;
            }
        }
        return null;
    }
}
